<?php
class Category extends DataObject  {
    
    static $db = array(
        'Name' => 'Varchar(130)'
    );
    
    static $belongs_many_many = array(
        'Shops' => 'Shop'
    );
    
    static $singular_name = 'Categorie';
    static $plural_name = 'Categorieen';
    
    static $field_labels = array(
	'Name' => 'Naam'
    );
    
    static $searchable_fields = array(
        'Name'
    );
    
    static $summary_fields = array(
        'Name' => 'Naam'
    );
    
    function getCMSFields() {   
                                
        $fields = parent::getCMSFields();
        $fields->removeByName('Shops');
        return $fields; 
        
    }
    
     public function canView($member = null) {
        return true;
    }
    
    public function canCreate($member = null) {
        if(!$member) $member = Member::currentUser();
        if(!$member) return false;
        return (
            Permission::checkMember($member, 'ADMIN')
            || Permission::checkMember($member, 'MANAGE_SHOPS')
        );
    }
    
    public function canEdit($member = null) {
        return $this->canCreate($member);
    }
 
    public function canDelete($member = null) {
        return $this->canCreate($member);
    }

}